package com.android.aRemote;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class SmartSwitchActivity extends Activity {
	private SmartSwitch mSmartSwitch = new SmartSwitch();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_smart_switch);
		((Button)findViewById(R.id.btnTurnOn1)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOff1)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOn2)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOff2)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOn3)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOff3)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOn4)).setOnClickListener(new ButtonListener());
		((Button)findViewById(R.id.btnTurnOff4)).setOnClickListener(new ButtonListener());
	}

	public class ButtonListener implements View.OnClickListener {

		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.btnTurnOn1:
				mSmartSwitch.Turn(0, 1);
				break;
			case R.id.btnTurnOff1:
				mSmartSwitch.Turn(0, 0);
				break;
			case R.id.btnTurnOn2:
				mSmartSwitch.Turn(1, 1);
				break;
			case R.id.btnTurnOff2:
				mSmartSwitch.Turn(1, 0);
				break;
			case R.id.btnTurnOn3:
				mSmartSwitch.Turn(2, 1);
				break;
			case R.id.btnTurnOff3:
				mSmartSwitch.Turn(2, 0);
				break;
			case R.id.btnTurnOn4:
				mSmartSwitch.Turn(3, 1);
				break;
			case R.id.btnTurnOff4:
				mSmartSwitch.Turn(3, 0);
				break;
			}
		}  		
	}
}
